<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/metro-gray/easyui.css"/>
<link rel="stylesheet" href="static/easyui/themes/icon.css"/>
<title>角色管理</title>
<style type="text/css">
  #dg{
    text-align: center;
    float: left;
  }
</style>
</head>

<body>

<script type="text/javascript">
$(function(){
	//角色表格
	 $('#dg').datagrid({
	    url:'',
	    pagination:true,
	    pageNumber:1,
	    pageSize:3,
	    pageList:[1,3],
	    columns:[[   
	    	{field:'check',checkbox:true},
	        {field:'code',title:'编号',width:238},    
	        {field:'name',title:'用户',width:280},    
	        {field:'price',title:'角色',width:280}, 
	        {field:'button',title:'操作',width:280}, 
	    ]]    
	});
}) ;   

//用户新怎按钮点击事件
function tianjia(target){
	 $('#xinzen').window('open');
}
//打开用户授权
function shouquan11(target){
	 $('#shouquan').window('open');
}

//关闭授权窗口
$("#close-grant").click(function(){
	$("#shouquan").window("close");
});
function qq(value,name){ 
	alert(value+":"+name) 
	} 
	
function qq(value){ 
	alert(value) 
	}  
/* 	
function grantwin(roleId){
	//去除表格的选中
	$("#dg").datagrid("unselectAll");
	$("#shouquan").attr("data-value",roleId);
	//打开窗口
	$("#shouquan").window("open");
	//初始化树形结构
	$("#grant-tree").tree({
		checkbox:true,
		url:'init-grant?roleId='+roleId,
		onlyLeafCheck:true
	})
}
//获取页面的二级功能id
var jq = top.jQuery;
var funId=jq("#tt").tabs("getSelected").panel('options').id;

//初始化三级的功能按钮
var btns = function(value,row,index){
	var str="";
	$.ajax({
		url:'init-thirdfuns',
		type:'post',
		data:{
			funId:funId//参数为2级的功能id
		},
		async:false,//是否异步刷新
		success:function(data){
			for (var i = 0; i < data.length; i++) {
				str += "<input type='button' onClick='"+data[i]['function_url']+"("+row.roleId+")' value='"+data[i]['function_name']+"'/>";
			}
		}
	})
	return str;
}

$(function(){
	

	//访问数据源、初始化表格
	$('#dg').datagrid({
	    url:'dg',
	    columns:[[
	    	{field:'check',checkbox:true},
	        {field:'code',title:'编号',width:238},    
	        {field:'name',title:'用户',width:280},    
	        {field:'price',title:'角色',width:280}, 
	        {field:'button',title:'操作',width:280}, 
				formatter:btns	
			}
	    ]]
	});
	
	//点击保存按钮，获得角色id和所有选中功能id
	$("#save-grant").click(function(){
		var roleId = $("#shouquan").attr("data-value");
		//获取树形结构中所有选中的节点
		var nodes = $('#grant-tree').tree('getChecked', ['checked','indeterminate']);
		//将所有节点的id存入数组
		var functionIds = [];
		for (var i = 0; i < nodes.length; i++) {
			//这是三级
			functionIds.push(nodes[i].id);
			//这是二级
			var parent = $("#grant-tree").tree("getParent", nodes[i].target);
			if(parent != null){
				functionIds.push(parent["id"]);
				//这是一级
				var root = $("#grant-tree").tree("getParent",parent.target);
				if(root != null){
					functionIds.push(root["id"]);
				}
			}
		}
		//去重
		function dedupe(array){
			 return Array.from(new Set(array));
		}
		functionIds = dedupe(functionIds) //保证一级和二级在数组中不重复
		//提交到controller
		$.ajax({
			url:'sava-grant',
			type:'post',
			data:{
				roleId:roleId,
				funIds:JSON.stringify(functionIds)
			},
			success:function(){
				$("#grant-win").window("close");
			}
		}); 
	});
}); */
	
</script>
<div class="maxbox easyui-panel"  data-options="fit:true" style="border:1px solid #F3F3F4;">
     <fieldset style="border:1px solid #A6A6A6;border-radius:6px;width:1050px;margin:0 auto;margin-top:40px;margin-bottom:20px;">
 	            <legend style="font-size:17px;">角色管理</legend>
 	          
        <div style="margin-bottom: 20px;margin-top: 20px;">
	          <div style="float: left;margin-right: 30px;">
	          		<input id="ss" class="easyui-searchbox" style="width:200px" data-options="searcher:qq,prompt:'请输入搜索的内容'"></input>
	          </div> 
		  	  <div class="button">
	    			<a id="btn" style="height: 25px" class="easyui-linkbutton"  data-options="iconCls:'icon-add'" onclick="tianjia(this)">添加</a> 
	          </div> 
		</div>
     <div class="jsxq">
       <table id="dg" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:1108" >
		    <tbody>
				<tr>
				   <td></td>
		    		<td data-options="field:'deptno'">2018001</td>
		    		<td>阿莫xxx</td>
		    		<td>2</td>
		    		<td><a id="btn" class="easyui-linkbutton" onclick="shouquan11(this)">授权</a><a id="btn" class="easyui-linkbutton">编辑角色</a></td>
		    	</tr>
				 <tr>
				   <td></td>
		    		<td data-options="field:'deptno'">2018001</td>
		    		<td>阿莫西林</td>
		    		<td>22.0</td>
		    		<td><a id="btn" class="easyui-linkbutton">授权</a><a id="btn" class="easyui-linkbutton">编辑角色</a></td>
		    	</tr>
			</tbody>
	  </table>
</div>  
    
      </fieldset>
      <!-- 角色新增 -->
	   <div id="xinzen" align="center" class="easyui-window" title="新增角色" style="width:300px;height:200px"  data-options="iconCls:'icon-save',modal:true,
	   resizable:false, minimizable:false,maximizable:false,shadow:true,collapsible:false,closed:true,zIndex:300">   
 	            <form id="ff" method="post">   
 	               <h3>新增角色</h3>
				     <div style="margin-top: 30px;margin-bottom: 10px">   
				        <label for="name" style="font-size:16px;">角色：</label>   
				        <input class="easyui-textbox" type="text" name="name" data-options="prompt:'请输入角色',height:28"/>   
				    </div>				     
				    <a style="margin-top:25px;" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">新增</a>
				</form>
		</div> 

 </div>
 
</body>
</html>